package com.backend.controller;

import com.backend.common.AddAss;
import com.backend.common.AdminForm;
import com.backend.common.GetAllUserContion;
import com.backend.common.UserPassword;
import com.backend.config.Result;
import com.backend.service.AdminService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user")
public class AdminController {

    @Autowired
    AdminService adminService;



    @PostMapping("/updateAdminPassword")
    Result updateUserPassword(@RequestBody UserPassword userPassword){
        return adminService.updateAdminPassword(userPassword);
    }

    @GetMapping("/lookUpAllUser")
    Result lookUpAllUser(){
        return adminService.lookUpAllUser();
    }


    @GetMapping("/AuditActionStatus")
    Result AuditActionStatus(@RequestParam("actionId") String actionId,@RequestParam("status") String status){
        return  adminService.AuditActionStatus(actionId,status);
    }

    @PostMapping("/adminLogin")
    Result adminLogin(@RequestBody AdminForm adminForm){
        return adminService.adminLogin(adminForm);
    }


    @GetMapping("/deleteAss")
    Result deleteAss(@RequestParam("assId")String assId ){
        return  adminService.deleteAss(assId);
    }

    @PostMapping("/getAssUserByAId")
    Result getAssUserByAId(@RequestBody GetAllUserContion getAllUserContion){
        return adminService.getAssUserByAId(getAllUserContion);
    }

    @PostMapping("/addAss")
    Result addAss(@RequestBody AddAss addAss){
        return adminService.addAss(addAss);
    }

    @PostMapping("/getAssUserByAssId")
    Result getAssUserByAssId(@RequestBody GetAllUserContion getAllUserContion){
        return adminService.getAssUserByAssId(getAllUserContion);
    }

    

    @GetMapping("/AssDeleteUserById")
    Result AssDeleteUserById(@RequestParam("stuId")String stuId,@RequestParam("assId")String assId){
        Integer i= adminService.AssDeleteUserById(stuId,assId);
        if(i==1){
            return Result.success("删除成功",1);
        }
        return Result.fail("删除失败",0);
    }

    @GetMapping("/AssUpdateUserDef")
    Result AssUpdateUserDef(@RequestParam("stuId")String stuId,@RequestParam("assId")String assId,@RequestParam("status")String status){
        Integer i= adminService.AssUpdateUserDef(stuId,assId,status);
        if(i==1){
            return Result.success("删除成功",1);
        }
        return Result.fail("删除失败",0);
    }

}
